package com.colortea.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.colortea.dao.CartTDao;
import com.colortea.entity.CartT;

@Repository("cartTDao")
public class CartTDaoImpl extends BaseTDaoImpl<CartT> implements CartTDao{
	
	private static final Logger log = LoggerFactory.getLogger(CartTDaoImpl.class);
	public List<CartT> findCartGoodsByOrderid(String orderid) {
		log.debug("find all findCartGoodsByOrderid ");
		try {
			String queryString = "from CartT as c where c.orderid=:orderid and c.state='3' order by addtime desc";
			Query createQuery = this.getSessionFactory().openSession().createQuery(queryString);
			createQuery.setParameter("orderid", orderid);
			List<CartT> list = createQuery.list();
			if (list != null && list.size() > 0) {
				return list;
			}
			return null;
		} catch (RuntimeException re) {
			log.error("find all findCartGoodsByOrderid  error", re);
			throw re;
		}
	}
}
